home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 05.zip / BS1 part 5 / IM_3 .adf / Exec / piarc.LZH / hist.rexx < prev    next >
OS/2 REXX Batch file  |  1992-07-11  |  4KB  |  137 lines

  1. /*
  2.  * histr.rexx
  3.  *
  4.  *  Written by: Pete Patterson
  5.  * Last Update: January 15, 1992
  6.  *         For: Black Belt Systems image processing series IM, IM F/c, and IP.
  7.  * ---------------------------------------------------------------------------
  8.  *    Revision: 1.0
  9.  */
  10.  
  11. /*
  12.  * open rexxsupport.library -- needed for some functions
  13.  */
  14. if ~show('L',"rexxsupport.library") then do
  15.   if addlib('rexxsupport.library',0,-30,0) then do
  16.       /* everything's ok */
  17.     end;
  18.   else do
  19.     say 'We Have A Library Problem, Unable To Load "rexxsupport.library"';
  20.     say 'Cannot operate targar.rexx without this library - sorry!';
  21.     exit 10;
  22.     end;
  23.   end;
  24.  
  25. /*
  26.  * This will automatically direct the script to the proper
  27.  * software, if it is running.
  28.  */
  29. prtnme = 'IP_Port'; /* assume Image Professional */
  30. if show('P','IP_Port') = 0 then do
  31.   if show('P','IM_Port') = 0 then do
  32.     say "Can't find image processor's ARexx port!!!"; /* not running? */
  33.     say "This script requires IP, IM or IM F/c to run!";
  34.     exit(20);
  35.     end;
  36.   else do
  37.     prtnme = 'IM_Port'; /* That's the thing about assumptions... */
  38.     end;                 /* We make em, user's break em.          */
  39.   end;
  40.  
  41. options;
  42. address;
  43.  
  44.   prevpath = 'ram:'; /* put user in ram to start with... */
  45.  
  46.   if show('C',histpath) = 1 then do
  47.     prevpath = getclip(histpath);
  48.     end;
  49.  
  50.   address(prtnme);
  51.   options results;
  52.   'current';
  53.   bufdata = result; /* get name of buffer, if there is one */
  54.   parse var bufdata bname ',' bnum ',' bx ',' by ',' btot ',' bmem ',' bparname ',' bparnum;
  55.   if bname ~= '<none>' then do
  56.     bufname = bname;
  57.     end;
  58.   'filerequest "'||prevpath||'","'||bufname||'","","Save HIST"';
  59.   histfile = result;
  60.   options;
  61.  
  62.   if histfile = 'FR_CANCELLED' then do
  63.     address(prtnme);
  64.     'imtofront';
  65.     exit 0;
  66.     end;
  67.  
  68.   histfile = expandfilename(histfile);
  69.   thispath = gimmepath(histfile);
  70.   call setclip(histpath,thispath);
  71.  
  72.   address(prtnme);
  73.   options results;
  74.   'jackin';
  75.   jackadr = result;
  76.   options;
  77.  
  78.   address command 'cmpi:hist '||jackadr||' "'||histfile||'" "'||bufname||'"';
  79.  
  80.   address(prtnme);
  81.   'imtofront';
  82.   address;
  83.  
  84.   exit 0;
  85.  
  86. /*
  87.  * gimmepath
  88.  *
  89.  * This takes the provided argument and sucks the path out of it, then
  90.  * returns that path to the caller, sans file name.
  91.  */
  92. gimmepath:
  93.   arg fullnamegx;
  94.     tempgx = reverse(fullnamegx);
  95.     lengx = length(fullnamegx);   /* get length of string */
  96.     slashdex = index(tempgx,'/'); /* first occurance of '/' from right */
  97.     colondex = index(tempgx,':');  /* first occurance of ':' from right */
  98.     seploc = 0; /* assumes current dir, no path supplied */
  99.     if slashdex ~= 0 then do /* we assume we are in a DIR */
  100.       seploc = (lengx - slashdex)+1;
  101.       end;
  102.     else do
  103.       if colondex ~= 0 then do /* we assume we are on a device */
  104.         seploc = (lengx - colondex)+1;
  105.         end;
  106.       end;
  107.   gxname = substr(fullnamegx,seploc+1); /* if you ever need it */
  108.   gxpath = left(fullnamegx,seploc);
  109.   return(gxpath);
  110.  
  111. /*
  112.  * Since this script can't be expected to know where the CD of the user
  113.  * is when this cmd is invoked, we have to check the path the user
  114.  * provides - if it's not specified right from a root, then we have
  115.  * to make it a complete specification from the root.
  116.  */
  117. expandfilename:
  118.   parse arg jfile;
  119.   if index(jfile,':') = 0 then do
  120.     curdir = pragma(D);
  121.     if right(curdir,1) ~= ':' then do
  122.       if right(curdir,1) ~= '/' then do
  123.         if curdir ~= '' then do
  124.           curdir = curdir || '/';
  125.           end;
  126.         end;
  127.       end;
  128.     jfile = curdir||jfile;
  129.     end;
  130.   return(jfile);
  131.  
  132. rvalue:
  133.   wordnum = c2d(readch(fhandle,1)) * 256;
  134.   wordnum = wordnum + c2d(readch(fhandle,1));
  135.   return wordnum;
  136.  
  137.